package com.taotao.rop.service;

import com.rop.annotation.HttpAction;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import com.taotao.rop.database.domain.RoleMenu;
import com.taotao.rop.database.mapper.RoleMenuMapper;
import com.taotao.rop.response.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@ServiceMethodBean(httpAction = HttpAction.POST, version = "1.0")
public class RoleMenuService {
    @Autowired
    private RoleMenuMapper roleMenuMapper;

    @ServiceMethod(method = "roleMenu.list")
    public Object listRoleMenu(RoleMenu request){
        List<RoleMenu> roleMenuList = roleMenuMapper.getList(request);

        BaseResponse<List<RoleMenu>> response = new BaseResponse<List<RoleMenu>>();
        response.setSuccess(true);
        response.setData(roleMenuList);
        return response;
    }

    @ServiceMethod(method = "roleMenu.insert")
    public Object insertRoleMenu(RoleMenu request){
        Integer count = roleMenuMapper.insertOne(request);

        BaseResponse<Integer> response = new BaseResponse<Integer>();
        response.setSuccess(true);
        response.setData(count);
        return response;
    }

    @ServiceMethod(method = "roleMenu.remove")
    public Object removeRoleMenu(RoleMenu request){
        Integer count = roleMenuMapper.removeOne(request);

        BaseResponse<Integer> response = new BaseResponse<Integer>();
        response.setSuccess(true);
        response.setData(count);
        return response;
    }
}
